﻿﻿using System;
using System.Collections.Generic;
using System.Text;
namespace WebApp.App.Models.Entity.Common
{
    public class channel:NRapid.Struct
    {
		public System.Int64 id;
		public System.Int64? type_id;
		public System.Int64? site_id;
		public System.String name;
		public System.String title;
		public System.Int64? sort_id;
		public System.String seo_folder;
		#region 从get列表初始化实体类
		public static bool TryParse(NRapid.NameValueCollection get,out channel par)
		{
			par=new channel();
			try
			{
						System.Int64.TryParse(get["id"],out par.id);
						par.type_id=null;
						if(get["type_id"]!=null)
						{
							par.type_id=System.Int64.Parse(get["type_id"]);
						}
						par.site_id=null;
						if(get["site_id"]!=null)
						{
							par.site_id=System.Int64.Parse(get["site_id"]);
						}
						par.name=get["name"];
						par.title=get["title"];
						par.sort_id=null;
						if(get["sort_id"]!=null)
						{
							par.sort_id=System.Int64.Parse(get["sort_id"]);
						}
						par.seo_folder=get["seo_folder"];
			}
			catch
			{
				return false;
			}
			return true;
		}
		#endregion
		#region 写Json字符串
		public override void WriteJson(System.IO.TextWriter tw)
		{
			tw.Write("{");
					tw.Write("\"id\":");
					tw.Write(id.ToString());
					tw.Write(",");
					tw.Write("\"type_id\":");
					tw.Write(type_id==null?"null" : type_id.ToString());
					tw.Write(",");
					tw.Write("\"site_id\":");
					tw.Write(site_id==null?"null" : site_id.ToString());
					tw.Write(",");
					tw.Write("\"name\":");
					tw.Write("\"");
					tw.Write(name==null?"null":name);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"title\":");
					tw.Write("\"");
					tw.Write(title==null?"null":title);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"sort_id\":");
					tw.Write(sort_id==null?"null" : sort_id.ToString());
					tw.Write(",");
					tw.Write("\"seo_folder\":");
					tw.Write("\"");
					tw.Write(seo_folder==null?"null":seo_folder);
					tw.Write("\"");
			tw.Write("}");
		}
		#endregion
    }
}